0

I'm working on a QNAP NAS-system (which alone is troublesome; firmware: 4.1.1 (not that new)) and installed duplicity through some community-package.

Problem

Logged in as admin (which is the replacement of root within QNAPs system) through ssh, the following works:

duplicity
Command line error: Expected 2 args, got 0
Enter 'duplicity --help' for help screen.

Trying the same as another user fails all the time (here: sudo -i):

sudo -i -u backupScript
duplicity
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

Also sudo --login:

sudo -u backupScript --login
duplicity
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

sudo -E (which could be a candidate) seems not be available with my version: 1.8.14p3.

Debugging env-setting:

admin: env

HOSTNAME=XXX
TERM=xterm
SHELL=/bin/sh
HISTSIZE=1000
SSH_CLIENT=192.168.2.106 55935 22
SSH_TTY=/dev/pts/5
LC_ALL=en_US.UTF-8
HISTFILESIZE=1000
USER=admin
TEMP=/Apps/opt/tmp
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:
PAGER=/bin/more
MAIL=/var/mail/admin
PATH=/Apps/opt/bin:/Apps/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin:/usr/local/ruby/bin:/Apps/bin:/Apps/sbin:/usr/local/jre/bin
INPUTRC=/etc/inputrc
PWD=/root
JAVA_HOME=/usr/local/jre
RUBY_PATH=/usr/local/ruby
EDITOR=/bin/vi
LANG=en_US.UTF-8
DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
PS1=[\w] #
SHLVL=1
HOME=/root
TERMINFO=/Apps/opt/share/terminfo
TMP=/Apps/opt/tmp
LOGNAME=admin
LC_CTYPE=en_US.UTF-8
SSH_CONNECTION=192.168.2.106 55935 192.168.2.103 22
_=/usr/bin/env

backupScript env after sudo -i -u backupScript

HOSTNAME=XXX
SHELL=/bin/sh
TERM=xterm
HISTSIZE=1000
LC_ALL=en_US.UTF-8
HISTFILESIZE=1000
USER=backupScript
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:
SUDO_USER=admin
SUDO_UID=0
USERNAME=backupScript
PAGER=/bin/more
MAIL=/var/mail/backupScript
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin:/usr/local/ruby/bin:/Apps/bin:/Apps/sbin:/usr/local/jre/bin
INPUTRC=/etc/inputrc
PWD=/share/homes/backupScript
JAVA_HOME=/usr/local/jre
RUBY_PATH=/usr/local/ruby
EDITOR=/bin/vi
LANG=en_US.UTF-8
DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
PS1=[\u@\h \W]\$
SHLVL=1
SUDO_COMMAND=/bin/sh
HOME=/share/homes/backupScript
LOGNAME=backupScript
LC_CTYPE=en_US.UTF-8
SUDO_GID=0
_=/usr/bin/env
  • Both doesn't have any PYTHONHOME defined (which is mentioned in the error)
  • How is admin able to run duplicity, while user backupScript is not?
  • Any ideas how to repair this?
  • Any ideas of further debugging-attemps? Just mention if i'm approaching this in a completely wrong way!
0

I guess in your case the main problem is that this is missing in $PATH: "/Apps/opt/bin:/Apps/opt/sbin". Probably python should come from there.

Actually sudo -i should work if user "backupScript" has the right profile/shell config files in his home /share/homes/backupScript. If not then change his profile or don't use --login or -i.

You could mimic sed -E behavior by editing /etc/sudoers. Either disable Defaults env_reset or add PATH to Defaults env_keep

BTW if admin is root then you don't even need to use sudo. su should be fine:

su -c duplicity backupScript

  • Thanks! The Apps-path is not the reason (tried adding it) and it also does not contain Python. su is not supported on my system (and sudo needed to be installed manually too). I will have a look at your other remarks! – sascha Sep 14 '16 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.