How to fix Synology Hyper Backup Explorer Insufficient Privileges Error

A quick guide to fix the following error message given in Hyper Backup Explorer when trying to access a usb backup.

synology-hyper-backup-explorer-insufficient-privileges

Insufficient privileges to access some subfolders under the destination shared folder. Please contact the destination administrator for assistance.

The application actually outputs the error to a log under the running directory called HyperBackupExplorer.log and contains the following

2017-06-03 01:28:57 PM (5775) [debug] target_manager.cpp:186 synobkpinfo.db [/media/user/drive/diskstation_backup/synobkpinfo.db] access failed Permission denied
2017-06-03 01:28:57 PM (5775) [debug] target_manager.cpp:186 synobkpinfo.db [/media/user/drive/diskstation_backup/synobkpinfo.db] access failed Permission denied
2017-06-03 01:28:57 PM backuptargetimpl.cpp:73 get target failed

A simple fix for this is to change the file permissions for the database file with the following command (note please change the media directory path with the correct mount path for the drive):

cd /media/user/drive/diskstation_backup/
sudo chmod o+r synobkpinfo.db

Ubuntu 17.04 Install Nvidia Drivers

Looking for Ubuntu 16.04/16.10?

Quick guide on how to install nvidia drivers on a fresh install of Ubuntu 17.04 with full disk encryption. The following steps were tested with a GTX 1070 and Intel HD Graphics 530 integrated graphics.

  • Boot and install via normal usb ubuntu installer
  • After installation reboot and login
  • Run update system software via terminal
sudo apt-get update && sudo apt-get upgrade
  • Reboot system
  • Switch to tty1 by ctl-alt-f1 and login
  • Stop x
sudo /etc/init.d/lightdm stop
  • Remove the default nouveau drivers:
sudo apt-get --purge remove xserver-xorg-video-nouveau
  • Add nvidia ppa and install correct driver version replacing nvidia-381 with whatever version you’d like
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-381
sudo nvidia-xconfig
  • Edit file /etc/default/grub with your favorite editor
  • Edit line 11
From: GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash noplymouth"
To:   GRUB_CMDLINE_LINUX_DEFAULT="quiet"
  • Uncomment line 25 and change to your monitor’s resolution (for aesthetics)
GRUB_GFXMODE=2560x1440
  • Then update grub and reboot
update-grub
reboot

Note: the first first booting after these changes might only show a black screen, just type in the encryption password and enter and it should login. This seems to only happen the first time.

Ubuntu 16.04 Install Nvidia Drivers

Looking for Ubuntu 17.10?

Quick guide on how to install nvidia drivers on Ubuntu 16.04 (tested with 16.04 and 16.04.1 installs with a GTX 1070 and Intel HD Graphics 530 integrated graphics).

  • Disable PCI graphics in the bios or switch to automatic
  • Shutdown and plug in the display output to integrated graphics
  • Boot and install via normal usb ubuntu installer
  • After installation reboot
  • Run update system software via terminal
sudo apt-get update && sudo apt-get upgrade
  • Reboot system
  • Switch to tty1 by ctl-alt-f1 and login
  • Stop x
sudo /etc/init.d/lightdm stop
  • Remove the default nouveau drivers [1]:
sudo apt-get --purge remove xserver-xorg-video-nouveau
  • Add nvidia ppa and install correct driver version replacing nvidia-367 with whatever version you’d like
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367
sudo nvidia-xconfig
  • Reboot and enable the PCI graphics back in the bios
  • Shutdown and switch display output back to the graphics card

Special notes about full disk encryption [2],[3],[4],[5]

  1. After reboot, only see a purple screen
  2. After reboot, only see a black screen
  3. Might see the decrypt splash but the keyboard is unresponsive

I had best results editing the grub config with the following via recovery mode

  • Reboot and hold down shift while booting to bring up the grub menu
  • Select advanced options for ubuntu and select ubuntu with recovery mode
  • Add networking to get the file system in read/write
  • Then add root and press enter for maintenance mode
  • Edit file /etc/default/grub with your favorite editor
  • Edit line to: GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash noplymouth"
  • Add line: GRUB_GFXPAYLOAD_LINUX=keep
  • Add line: GRUB_GFXMODE=2560x1440
  • Then update grub and reboot
update-grub
reboot

Completed grub file looking simpler to:

# /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash noplymouth"
GRUB_CMDLINE_LINUX=""
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=2560x1440

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

[1] https://help.ubuntu.com/community/BinaryDriverHowto/Nvidia#RemovingNouveau.28advanced.2Fexpert_users.29

[2] http://askubuntu.com/questions/689064/cant-enter-password-for-luks-disk-encryption-after-nvidia-drivers-installed

[3] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1359689/comments/73

[4] https://bugs.launchpad.net/ubuntu/+source/plymouth/+bug/1386005/comments/72

[5] http://askubuntu.com/questions/362722/how-to-fix-plymouth-splash-screen-in-all-ubuntu-releases

Auditing in Spring Data JPA JavaConfig

In addition to the reference documentation of spring data jpa auditing. This is my interpretation of how to implement auditing and auditor aware in spring applications using JavaConfig. Please note that this requires having version 1.5.0.RELEASE or greater.

First, I created a base abstract class for entities which will hold definitions for created, last modified by and created, last modified by date. These can be described by using annotations @CreatedBy, @LastModifiedBy, @CreatedDate, and @LastModifiedDate. In this case I used joda time to define the type of date. The reference documentation also mentions adding AuditingEntityListener to the orm.xml file, however, if you wish to not include a xml file, you can add @EntityListeners(AuditingEntityListener.class) annotation to the abstract entity class. Here is an example:

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class AbstractEntity {

    @CreatedDate
    @NotNull
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime createdDate = DateTime.now();

    @LastModifiedDate
    @NotNull
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime lastModifiedDate = DateTime.now();

    @CreatedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    @NotNull
    private Account createdBy;

    @LastModifiedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    @NotNull
    private Account lastModifiedBy;

    ...
}

For created by and last modified by to be filled in with spring security principal information you use the AuitorAware<T> interface. Here is an example calling the account service to gain access for the current account information. The @Component annotation was used so a bean definition did not need to be defined in the configuration class which was suggested in the reference documentation.

@Component
public class SpringSecurityAuditorAware implements AuditorAware<Account> {

    @Inject private AccountService service;

    @Override
    public Account getCurrentAuditor() {
        return service.getCurrentAccount();
    }

}
@Override
public Account getCurrentAccount() {
    SecurityContext securityContext = SecurityContextHolder.getContext();
    UserDetailsCustom springSecurityUser = (UserDetailsCustom) securityContext.getAuthentication().getPrincipal();
    return springSecurityUser.getAccount();
}

Finally, add the annotation @EnableJpaAuditing to have the configuration be loaded. Also be sure to add jadira.usertype.databaseZone to the hibernation configuration (in this case) to set the timezone for joda time.

@Configuration
@EnableJpaAuditing(auditorAwareRef = "springSecurityAuditorAware")
...
public class DataBaseConfig { }

Testing Implementation for Integration Tests

If you care about testing (and you should), here are some tips one getting auditing working with your integration tests. First, create a new component for a mock auditor aware class. This will allow for auditing without the need for spring security.

@Component
public class MockAuditorAware implements AuditorAware<Account> {

    private Account currentAuditor;

    @Override
    public Account getCurrentAuditor() { return currentAuditor; }
    public void setCurrentAuditor(Account account) {this.currentAuditor = account; }

}

Be sure to add the mock auditor aware reference in the test configuration class.

@Configuration
@EnableJpaAuditing(auditorAwareRef = "mockAuditorAware")
...
public class TestConfig { }

Finally, in a base integrations test class, you can add a before statement for setting the auditor for all your tests:

@PersistenceContext protected EntityManager em;
@Inject protected MockAuditorAware auditorAware;

@Before
public void wireUpAuditor() {
    auditorAware.setCurrentAuditor(em.getReference(Account.class, 1));
}

Ubuntu 12.10 Install Eclipse with Android

Reference for installing Eclipse in Ubuntu 12.10 with the intention of installing Android afterwards. If you are not intending to install Android you can leave out installing ia32-libs and the ADT plugin.

  1. Download Eclipse

  2. Install requirements:

    # openjdk is for java
    # ia32-libs is the 32-bits libs for Android (only needed for 64-bit)
    sudo apt-get install openjdk-7-jdk ia32-libs
    
  3. Extract the eclipse tar:

    tar -xzf eclipse.tar.gz
    
  4. Move folder into opt directory:

    sudo mv eclipse /opt/
    
  5. Create the desktop profile for unity:

    sudo gedit /usr/share/applications/eclipse.desktop
    # Enter the below text:
    #######################
    [Desktop Entry]
    Name=Eclipse
    Type=Application
    Exec=/opt/eclipse/eclipse
    Terminal=false
    Icon=/opt/eclipse/icon.xpm
    Comment=Integrated Development Environment
    NoDisplay=false
    Categories=Development;IDE
    Name[en]=eclipse.desktop
    
  6. Create a symbolic link in your bin folder:

    sudo ln -s /opt/eclipse/eclipse /usr/local/bin/eclipse
    
  7. Clean launch eclipse for the first time:

    /opt/eclipse/eclipse -clean &
    
  8. Install ADT Plugin (Help -> Install New Software):

    https://dl-ssl.google.com/android/eclipse/