Config file used under Sudo changed

Hi all,

I've recently upgraded my install of RClone from 1.47 to 1.49.3 on an Ubuntu 18.04.3 LTS Server and am running into an odd issue.

I have a number of backup jobs set using scripts fired off in the root crontab which started failing after the update. It looks like for some reason now that when running sudo it is using my standard accounts config file which doesn't have any remotes configured instead of the config file under root. Also any new remotes I configure with 'sudo rclone config' also go into my standard user config?

If I run rclone config file I get the below which is fine:
Configuration file is stored at:
/home/myaccountname/.config/rclone/rclone.conf

but if I run sudo rclone config file I get:
Configuration file is stored at:
/home/myaccountname/.config/rclone/rclone.conf

where I used to get:
Configuration file is stored at:
/root/.config/rclone/rclone.conf

Have I gotten some permissions wrong or has something changed in the code now where running sudo/root still uses the standard config file rather than the config file stored in the root directory?

Help would be much appreciated.

That's definitely a bit strange and the upgrade should not cause that.

What does this show?

[felix@gemini ~]$ sudo env | grep RCLONE

Strange indeed. It should definitely work as you expected it to. A different user will have a different config location by default (a source of confusion for many beginners actually).

The only thing I know that overrides this is if you have an rclone config file in the same folder as rclone.exe . In that case it will always use that no matter what. Useful to be aware of - but that does not seem to be the case here.

I am not aware that this behavior has changed in any recent versions. NCW is very conscious about making any changes that would break existing configurations, so it is extremely unlikely he would do anything like this outside of maybe a full version 2.0 overhaul in the future.

If it is a Linux spesific issue I have to leave you in Animosity's very capable hands...

Doesnt display anything with upper or lowercase rclone. My output of just sudo env is below:

LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=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:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:

LANG=en_US.UTF-8

HOME=/home/myuseraccount

TERM=xterm-256color

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

MAIL=/var/mail/root

LOGNAME=root

USER=root

USERNAME=root

SHELL=/bin/bash

SUDO_COMMAND=/usr/bin/env

SUDO_USER=myuseraccount

SUDO_UID=1000

SUDO_GID=1000

Just for fun, what happens when you flip over all the way?

[felix@gemini ~]$ sudo su -
Last login: Fri Sep 27 14:07:08 EDT 2019 on pts/0
[root@gemini ~]# rclone config file
Configuration file doesn't exist, but rclone will use this path:
/root/.config/rclone/rclone.conf
[root@gemini ~]#

This is probably the culprit. Any changes recently that may affected this? Generally, in Ubuntu, any sudo command preserves the HOME directory by default so the config in the /root shouldn't have been used even with the earlier versions of rclone.

Neat.

That would be it:

[root@gemini ~]# HOME=/blah
[root@gemini root]# rclone config file
Configuration file doesn't exist, but rclone will use this path:
/blah/.config/rclone/rclone.conf

Always love to learn something new as I that makes perfect sense.

So 1.48 had this change item:

https://rclone.org/changelog/#v1-48-0-2019-06-15

Use go-homedir to read the home directory more reliably (Nick Craig-Wood)

Would surmise that picks up the home directory better which is the fix that caused the issue to pop up.

[root@gemini rclone-v1.47.0-linux-amd64]# ./rclone config file
Configuration file doesn't exist, but rclone will use this path:
/root/.config/rclone/rclone.conf
[root@gemini rclone-v1.47.0-linux-amd64]# cd
[root@gemini ~]# rclone config file
Configuration file doesn't exist, but rclone will use this path:
/blah/.config/rclone/rclone.conf
1 Like

Yeah, looks like it.

Great find.

Yes that is it... the use of go-homedir

Rclone has enough users now that for every bug I fix, I break someone's workflow who was relying on that bug!

Can't exactly worry about that - bugs aren't features :smiley: (well, outside the corporate world anyway).
Very nice catch Animosity.

Ah ok well that explains it!

What would be the best way for me to update the config file under root now that sudo rclone config is editing my standard account config instead of roots. As root crontab is using the config file under root.

Or should I change the crontab jobs over to using my standard accounts crontab?

Cheers

You want to fix root so it points to the proper home directory rather than another user. Not sure how that happened either. I'd check /etc/password first:

[root@gemini ~]# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.